package com.witframework.web.tag.tab;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.BodyContent;
import javax.servlet.jsp.tagext.BodyTagSupport;

public class selectPanelTag extends BodyTagSupport implements tabbedpanel {
	private String id = null;
	private boolean script = false;

	public void setId(String paramString) {
		this.id = paramString;
	}

	public String getId() {
		return this.id;
	}

	public void setScript(boolean paramBoolean) {
		this.script = paramBoolean;
	}

	public boolean getScript() {
		return this.script;
	}

	public int doAfterBody() throws JspException {
		int i;
		String str2;
		BodyContent localBodyContent = getBodyContent();
		String str1 = "1";
		if (localBodyContent != null)
			str1 = localBodyContent.getString();
		try {
			i = Integer.parseInt(str1);
		} catch (Exception localException1) {
			throw new JspException("selectPanel: invalid number");
		}
		if (i <= 0)
			throw new JspException("selectPanel: invalid number");
		tabpanelTag localtabpanelTag = (tabpanelTag) findAncestorWithClass(this, tabpanelTag.class);
		if ((localtabpanelTag == null) && (this.id == null))
			throw new JspException("selectPanel: could not get tabPanel id");
		localBodyContent.clearBody();
		StringBuffer localStringBuffer = new StringBuffer("");
		if (localtabpanelTag != null)
			this.script = true;
		if (this.script)
			localStringBuffer.append("\n<script language=\"JavaScript\">\n");
		localStringBuffer.append("cjselectTab");
		if (this.id != null)
			str2 = this.id;
		else
			str2 = localtabpanelTag.getId();
		localStringBuffer.append(str2);
		localStringBuffer.append("(" + (i - 1));
		localStringBuffer.append(",pac");
		localStringBuffer.append(str2);
		localStringBuffer.append(",piac");
		localStringBuffer.append(str2);
		localStringBuffer.append(");");
		if (this.script)
			localStringBuffer.append("</script>\n");
		if (localtabpanelTag == null) {
			JspWriter localJspWriter = localBodyContent.getEnclosingWriter();
			try {
				localJspWriter.print(localStringBuffer.toString());
			} catch (Exception localException2) {
				throw new JspException("selectPanel: could not write body");
			}
		} else {
			localtabpanelTag.setLastWish(localStringBuffer.toString());
		}
		return 0;
	}

	public int doEndTag() {
		dropData();
		return 6;
	}

	public void release() {
		dropData();
	}

	private void dropData() {
		this.id = null;
		this.script = false;
	}
}